package com.flower.enjoyment.flower.controller;

import com.flower.enjoyment.flower.service.FlowersCardOrderService;
import com.flower.enjoyment.flower.service.OrderInfoService;
import com.flower.enjoyment.flower.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class JobController {
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private OrderInfoService orderInfoService;
    @Autowired
    private FlowersCardOrderService flowersCardOrderService;

    @Autowired
    private UserInfoService userInfoService;

    @Scheduled(cron = "0 0/1 * * * ? ")
    public void scheduled(){
        orderInfoService.updateExpireOrder();
        flowersCardOrderService.updateExpireCardOrder();
        logger.info("=====>>>>>使用cron  {}",System.currentTimeMillis());
    }

    @Scheduled(cron = "0 0 0 * * ?")
    public void initTodayIncome(){

        int result = userInfoService.updateTodayIncome();
        logger.info("=====>>>>>执行清楚今日收入操作  {}",result);
    }
}
